package apache.common;


import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang.math.RandomUtils;

import java.util.ArrayList;
import java.util.List;

public class StringDemo {
    public static void main(String[] args) {
        //字符串
        //判断是否为空
        System.out.println(StringUtils.isBlank("abcd__   "));//false
        System.out.println(StringUtils.isBlank("   "));//true
        System.out.println(StringUtils.isBlank(null));//true
        //集合
        List<String> list = new ArrayList<String>();
        System.out.println(CollectionUtils.isEmpty(list));//true
        list = null;
        System.out.println(CollectionUtils.isEmpty(list));//true
        //转换器
        System.out.println(NumberUtils.toInt("3", -1));//3
        System.out.println(NumberUtils.toInt("3a", -1));//-1
        System.out.println(NumberUtils.toInt(" "));//0
        System.out.println(NumberUtils.toInt("3a"));//0
        //随机数
        System.out.println(RandomUtils.nextInt(5));//随机整数
        System.out.println(RandomStringUtils.randomAlphabetic(6));//随机6位字母
        System.out.println(RandomStringUtils.randomNumeric(6));//随机6位数字


        System.out.println(NumberUtils.toInt("sdfsdf", 20));

    }
}
